package cn.zwx.base.enums;


import java.util.Objects;

/**
 * 返回错误码
 *
 * @author: jiangqk
 * @email: runner8013 @gmail.com
 * @date: 2018 /9/14 18:56
 * @Modified By :
 */
public enum RetCode {

    //系统返回码
    SUCC("000000", "处理成功"),
    FAIL("999998", "失败"),
    FLOW_ERROR("9999666", "网络堵车,请稍后重试!!!"),

    GOODS_SERVICE("2000000", "商品服务调用异常"),

    ORDER_SERVICE("3000000", "订单服务调用异常"),

    PARAM_ERROR("100001", "请求参数错误"),
    SIGN_ERROR("100002", "签名错误"),
    JSON_CONVERT_ERROR("100003", "JSON转换异常"),
    TIME_OUT("100004", "请求时间间隔过长"),
    PARAM_TYPE_ERROR("100005", "请求参数类型错误");

    /**
     * 错误码
     */
    private String code;

    /**
     * 错误描述
     */
    private String msg;

    RetCode(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static RetCode getRetCode(String code) {
        for (RetCode nameEnum : values()) {
            if (Objects.equals(nameEnum.getCode(), code)) {
                return nameEnum;
            }
        }
        return null;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
